home *** CD-ROM | disk | FTP | other *** search
Wrap
package java.security; import java.lang.ref.Reference; import java.lang.ref.WeakReference; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; public class Provider$Service { private String type; private String algorithm; private String className; private final Provider provider; private List<String> aliases; private Map<Provider.UString, String> attributes; private volatile Reference<Class> classRef; private volatile Boolean hasKeyAttributes; private String[] supportedFormats; private Class[] supportedClasses; private boolean registered; private static final Class[] CLASS0 = new Class[0]; private Provider$Service(Provider var1) { this.provider = var1; this.aliases = Collections.emptyList(); this.attributes = Collections.emptyMap(); } private boolean isValid() { return this.type != null && this.algorithm != null && this.className != null; } private void addAlias(String var1) { if (this.aliases.isEmpty()) { this.aliases = new ArrayList(2); } this.aliases.add(var1); } void addAttribute(String var1, String var2) { if (this.attributes.isEmpty()) { this.attributes = new HashMap(8); } this.attributes.put(new Provider.UString(var1), var2); } public Provider$Service(Provider var1, String var2, String var3, String var4, List<String> var5, Map<String, String> var6) { if (var1 != null && var2 != null && var3 != null && var4 != null) { this.provider = var1; this.type = Provider.access$900(var2); this.algorithm = var3; this.className = var4; if (var5 == null) { this.aliases = Collections.emptyList(); } else { this.aliases = new ArrayList(var5); } if (var6 == null) { this.attributes = Collections.emptyMap(); } else { this.attributes = new HashMap(); for(Map.Entry var8 : var6.entrySet()) { this.attributes.put(new Provider.UString((String)var8.getKey()), var8.getValue()); } } } else { throw new NullPointerException(); } } public final String getType() { return this.type; } public final String getAlgorithm() { return this.algorithm; } public final Provider getProvider() { return this.provider; } public final String getClassName() { return this.className; } private final List<String> getAliases() { return this.aliases; } public final String getAttribute(String var1) { if (var1 == null) { throw new NullPointerException(); } else { return (String)this.attributes.get(new Provider.UString(var1)); } } public Object newInstance(Object var1) throws NoSuchAlgorithmException { if (!this.registered) { if (this.provider.getService(this.type, this.algorithm) != this) { throw new NoSuchAlgorithmException("Service not registered with Provider " + this.provider.getName() + ": " + this); } this.registered = true; } try { Provider.EngineDescription var2 = (Provider.EngineDescription)Provider.access$1000().get(this.type); if (var2 == null) { return this.newInstanceGeneric(var1); } else if (var2.constructorParameterClassName == null) { if (var1 != null) { throw new InvalidParameterException("constructorParameter not used with " + this.type + " engines"); } else { Class var9 = this.getImplClass(); return var9.newInstance(); } } else { Class var3 = var2.getConstructorParameterClass(); if (var1 != null) { Class var4 = var1.getClass(); if (!var3.isAssignableFrom(var4)) { throw new InvalidParameterException("constructorParameter must be instanceof " + var2.constructorParameterClassName.replace('$', '.') + " for engine type " + this.type); } } Class var10 = this.getImplClass(); Constructor var5 = var10.getConstructor(var3); return var5.newInstance(var1); } } catch (NoSuchAlgorithmException var6) { throw var6; } catch (InvocationTargetException var7) { throw new NoSuchAlgorithmException("Error constructing implementation (algorithm: " + this.algorithm + ", provider: " + this.provider.getName() + ", class: " + this.className + ")", var7.getCause()); } catch (Exception var8) { throw new NoSuchAlgorithmException("Error constructing implementation (algorithm: " + this.algorithm + ", provider: " + this.provider.getName() + ", class: " + this.className + ")", var8); } } private Class getImplClass() throws NoSuchAlgorithmException { try { Reference var1 = this.classRef; Class var2 = var1 == null ? null : (Class)var1.get(); if (var2 == null) { ClassLoader var3 = this.provider.getClass().getClassLoader(); if (var3 == null) { var2 = Class.forName(this.className); } else { var2 = var3.loadClass(this.className); } this.classRef = new WeakReference(var2); } return var2; } catch (ClassNotFoundException var4) { throw new NoSuchAlgorithmException("class configured for " + this.type + "(provider: " + this.provider.getName() + ")" + "cannot be found.", var4); } } private Object newInstanceGeneric(Object var1) throws Exception { Class var2 = this.getImplClass(); if (var1 == null) { Object var9 = var2.newInstance(); return var9; } else { Class var3 = var1.getClass(); Constructor[] var4 = var2.getConstructors(); for(int var5 = 0; var5 < var4.length; ++var5) { Constructor var6 = var4[var5]; Class[] var7 = var6.getParameterTypes(); if (var7.length == 1 && var7[0].isAssignableFrom(var3)) { Object var8 = var6.newInstance(var1); return var8; } } throw new NoSuchAlgorithmException("No constructor matching " + var3.getName() + " found in class " + this.className); } } public boolean supportsParameter(Object var1) { Provider.EngineDescription var2 = (Provider.EngineDescription)Provider.access$1000().get(this.type); if (var2 == null) { return true; } else if (!var2.supportsParameter) { throw new InvalidParameterException("supportsParameter() not used with " + this.type + " engines"); } else if (var1 != null && !(var1 instanceof Key)) { throw new InvalidParameterException("Parameter must be instanceof Key for engine " + this.type); } else if (!this.hasKeyAttributes()) { return true; } else if (var1 == null) { return false; } else { Key var3 = (Key)var1; if (this.supportsKeyFormat(var3)) { return true; } else { return this.supportsKeyClass(var3); } } } private boolean hasKeyAttributes() { Boolean var1 = this.hasKeyAttributes; if (var1 == null) { synchronized(this) { String var3 = this.getAttribute("SupportedKeyFormats"); if (var3 != null) { this.supportedFormats = var3.split("\\|"); } var3 = this.getAttribute("SupportedKeyClasses"); if (var3 != null) { String[] var4 = var3.split("\\|"); ArrayList var5 = new ArrayList(var4.length); for(String var9 : var4) { Class var10 = this.getKeyClass(var9); if (var10 != null) { var5.add(var10); } } this.supportedClasses = (Class[])var5.toArray(CLASS0); } boolean var14 = this.supportedFormats != null || this.supportedClasses != null; var1 = var14; this.hasKeyAttributes = var1; } } return var1; } private Class getKeyClass(String var1) { try { return Class.forName(var1); } catch (ClassNotFoundException var4) { try { ClassLoader var2 = this.provider.getClass().getClassLoader(); if (var2 != null) { return var2.loadClass(var1); } } catch (ClassNotFoundException var3) { } return null; } } private boolean supportsKeyFormat(Key var1) { if (this.supportedFormats == null) { return false; } else { String var2 = var1.getFormat(); if (var2 == null) { return false; } else { for(String var6 : this.supportedFormats) { if (var6.equals(var2)) { return true; } } return false; } } } private boolean supportsKeyClass(Key var1) { if (this.supportedClasses == null) { return false; } else { Class var2 = var1.getClass(); for(Class var6 : this.supportedClasses) { if (var6.isAssignableFrom(var2)) { return true; } } return false; } } public String toString() { String var1 = this.aliases.isEmpty() ? "" : "\r\n aliases: " + this.aliases.toString(); String var2 = this.attributes.isEmpty() ? "" : "\r\n attributes: " + this.attributes.toString(); return this.provider.getName() + ": " + this.type + "." + this.algorithm + " -> " + this.className + var1 + var2 + "\r\n"; } // $FF: synthetic method static boolean access$000(Provider$Service var0) { return var0.isValid(); } // $FF: synthetic method Provider$Service(Provider var1, Provider.1 var2) { this(var1); } // $FF: synthetic method static String access$302(Provider$Service var0, String var1) { return var0.type = var1; } // $FF: synthetic method static String access$402(Provider$Service var0, String var1) { return var0.algorithm = var1; } // $FF: synthetic method static void access$500(Provider$Service var0, String var1) { var0.addAlias(var1); } // $FF: synthetic method static String access$602(Provider$Service var0, String var1) { return var0.className = var1; } // $FF: synthetic method static List access$700(Provider$Service var0) { return var0.getAliases(); } // $FF: synthetic method static Map access$800(Provider$Service var0) { return var0.attributes; } }